-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add unchecked-type-assertion #889
Add unchecked-type-assertion #889
Conversation
652dc0a
to
de3b67b
Compare
@denisvmedia |
@chavacava I can, but I think this should be a part of the tests ;) |
I totally agree! Unfortunately I am a bit short of time this week but will work on the suggested ideas ASAP. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's all good from my POV (just a small issue in the test case). Good job 👍
Just one thing came to my mind now, probably this is still left out (sorry, can't check it now): |
good idea.. let me write a test 👍 |
|
||
```go | ||
foo, _ := bar(.*Baz). | ||
// ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be interesting to list all the cases the rule is capable to detect (switch, channel, ...)
u.Lock() | ||
defer u.Unlock() | ||
|
||
if len(arguments) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a configured
field to the rule's struct to trace the rule's configuration was already processed and then quit ASAP once the rule was configured a first time.
if len(arguments) == 0 { | |
if len(arguments) == 0 || u.configured { |
Closes #888
Unchecked type assertions results can (and will) result in an unexpected panic and should be a lint.
This new rule covers this with configurable non-default option to ignore
foo, _ := bar.(Baz)
- cases where theok
value is ignored.See tests.